import { Api } from 'pf-component';
import { BaseApi, ServiceEnum } from '@/constants/api/base-api';
import { MethodTypeEnum } from '@/constants/enum/method-type.enum';

class CamundaApi {
  processApi: Api = {};
  processOrgApi: Api = {};
  processFormApi: Api = {};
  processTaskApi: Api = {};

  constructor() {
    this.initKm();
  }

  initKm() {
    this.processFormApi = {
      startFormKey: {
        url: this.getUrl() + '/form/start/key',
        method: MethodTypeEnum.GET
      },
      startFormData: {
        url: this.getUrl() + '/form/start/data',
        method: MethodTypeEnum.GET
      },
      taskFormKey: {
        url: this.getUrl() + '/form/task/key',
        method: MethodTypeEnum.GET
      },
      taskFormData: {
        url: this.getUrl() + '/form/task/data',
        method: MethodTypeEnum.GET
      }
    };
    this.processTaskApi = {
      queryDoneNode: {
        url: this.getUrl() + '/task/queryDoneNode',
        method: MethodTypeEnum.GET
      },
      queryDoneTaskForProcess: {
        url: this.getUrl() + '/task/queryDoneTask/process',
        method: MethodTypeEnum.POST
      },
      queryDoneTaskForUser: {
        url: this.getUrl() + '/task/queryDoneTask/user',
        method: MethodTypeEnum.POST
      },
      queryTodo: {
        url: this.getUrl() + '/task/query/todo',
        method: MethodTypeEnum.GET
      },
      queryDone: {
        url: this.getUrl() + '/task/query/done',
        method: MethodTypeEnum.GET
      },
      commit: {
        url: this.getUrl() + '/task/to/commit',
        method: MethodTypeEnum.PUT
      },
      reject: {
        url: this.getUrl() + '/task/to/reject',
        method: MethodTypeEnum.PUT
      },
      trans: {
        url: this.getUrl() + '/task/to/trans',
        method: MethodTypeEnum.PUT
      }
    };
    this.processOrgApi = {
      effectUserList: {
        url: this.getUrl() + '/flowOrg/effectList/user',
        method: MethodTypeEnum.GET
      },
      effectDeptList: {
        url: this.getUrl() + '/flowOrg/effectList/dept',
        method: MethodTypeEnum.GET
      }
    };
    this.processApi = {
      deploy: {
        url: this.getUrl() + '/process/deploy',
        method: MethodTypeEnum.PUT
      },
      deployList: {
        url: this.getUrl() + '/process/list',
        method: MethodTypeEnum.POST
      },
      del: {
        url: this.getUrl() + '/process',
        method: MethodTypeEnum.DELETE
      },
      startById: {
        url: this.getUrl() + '/process/start/id',
        method: MethodTypeEnum.PUT
      },
      startByKey: {
        url: this.getUrl() + '/process/start/key',
        method: MethodTypeEnum.PUT
      },
      getResource: {
        url: this.getUrl() + '/process/resource',
        method: MethodTypeEnum.GET
      }
    };
  }
  getUrl(): string {
    return BaseApi.getUrl(ServiceEnum.camunda);
  }
}
export const camundaApi = new CamundaApi();
